package com.hy.lightning.ds;

import java.sql.Connection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.hy.lightning.ds.jdbc.datasources.JdbcConf;

public interface JdbcDataSource {
	
	static Map<String, JdbcConf> conf_map = new ConcurrentHashMap<>();
	
	/**
	 * 初始化数据库连接池
	 * @param redisConfs
	 */
	public static void initDataSource(JdbcConf ...jdbcConfs){
		for(JdbcConf jdbcConf: jdbcConfs) {
			if (!conf_map.containsKey(jdbcConf.getKey())) {
				conf_map.put(jdbcConf.getKey(), jdbcConf);
			}
		}
	}
	
	/**
	 * 获取数据库连接
	 * @param dataSourceKey 数据库连接池key
	 * @return
	 */
	Connection getConnection(String dataSourceKey);
	
	/**
	 * 获取数据库连接
	 * 
	 * @return
	 */
	Connection getConnection();
}
